unit history;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
  Grids;

type

  { TfrmHistory }

  TfrmHistory = class(TForm)
    StringGrid: TStringGrid;
    procedure FormShow(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  frmHistory: TfrmHistory;

implementation

{$R *.lfm}

{ TfrmHistory }
uses main;

procedure TfrmHistory.FormShow(Sender: TObject);
var
  i:Integer;
begin
  frmMain.ZQuery.SQL.Text:='SELECT * FROM history ORDER BY id DESC';
  frmMain.ZQuery.Open;
  frmMain.ZQuery.First;
  StringGrid.Clear;
  StringGrid.RowCount:=1;
  StringGrid.RowCount:=FrmMain.ZQuery.RecordCount+1;
  for i:=1 to frmMain.ZQuery.RecordCount do begin
    StringGrid.Cells[1,i] := frmMain.ZQuery.FieldByName('id').AsString;
    StringGrid.Cells[2,i] := frmMain.ZQuery.FieldByName('date').AsString;
    StringGrid.Cells[3,i] := frmMain.ZQuery.FieldByName('title').AsString;
    StringGrid.Cells[4,i] := frmMain.ZQuery.FieldByName('info').AsString;
    frmMain.ZQuery.Next;
  end;
  frmMain.ZQuery.Active:=False;
end;

end.

